package com.baosight.risk.web.quartz;

import java.util.List;

import javax.ws.rs.core.MediaType;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baosight.risk.api.quartz.ISysJobParamService;
import com.baosight.risk.base.controller.BaseController;
import com.baosight.risk.common.annotation.Log;
import com.baosight.risk.common.enums.BusinessType;
import com.baosight.risk.common.result.AjaxResult;
import com.baosight.risk.service.quartz.entity.SysJobParam;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;


/**
 * 
 * @author zzw
 *
 */
@Slf4j
@RestController
@RequestMapping("system/jobparam")
@Api(value = "定时任务参数", description = "定时任务参数管理", produces = MediaType.APPLICATION_JSON)
public class SysJobParamController extends BaseController {
    @Autowired
    private ISysJobParamService jobParamService;

    /**
     * 查询职能机构信息（全部数据）
     *
     * @param org
     * @return
     */
    @PostMapping("list")
    @ApiOperation("查询定时任务参数配置")
    public AjaxResult list(@RequestBody SysJobParam jobParam) {
        log.info("查询定时任务参数配置：" + jobParam.toString());

        List<SysJobParam> result = jobParamService.select(jobParam);

        return success("查询成功", result);
    }
    
    /**
     * 保存定时任务参数配置
     * @param jobParam
     * @return
     */
    @PostMapping("save")
    @Log(title = "保存定时任务参数配置")
    @ApiOperation("保存定时任务参数配置")
    @RequiresPermissions("system:jobparam:save")
    public AjaxResult save(@RequestBody SysJobParam jobParam) {
        log.info("保存定时任务参数配置：" + jobParam.toString());
        return toAjax(jobParamService.save(jobParam));
    }
    
    /**
     * 删除定时任务参数配置
     * @param id
     * @return
     */
    @GetMapping("delete")
    @Log(title = "删除定时任务参数配置", businessType = BusinessType.DELETE)
    @RequiresPermissions("system:jobparam:delete")
    @ApiOperation("删除定时任务参数配置")
    public AjaxResult delete(@RequestParam("id") String id) {
        return toAjax(jobParamService.deleteById(id));
    }

    @GetMapping("queryManageCompByGobGuid")
    @Log(title = "得到管理单位配置", businessType = BusinessType.DELETE)
    @RequiresPermissions("system:jobparam:queryManageCompByGobGuid")
    @ApiOperation("得到管理单位配置")
    public AjaxResult queryManageCompByGobGuid(@RequestParam("jobGuid") String jobGuid) {
        return success("",jobParamService.queryManageCompConfig(jobGuid));
    }
}
